<%# locals: (url: request.path, csrf_url: url, text: "Delete", confirmation: nil, confirmation_message: nil, redirect: request.path, method: "DELETE") %>

<% button = part(
  "components/button",
  text: text,
  icon: "hero-trash",
  extra_class: "delete-btn",
  type: "danger",
  attributes: {
    "data-url" => url,
    "data-csrf" => csrf_token(csrf_url, method),
    "data-confirmation" => confirmation,
    "data-confirmation-message" => confirmation_message,
    "data-redirect" => redirect,
    "data-method" => method
  }
) %>

<% if method == "POST" %>
  <form method="POST" action="<%= url %>">
    <%== csrf_tag(url) %>
    <%== button %>
  </form>
<% else %>
  <%== button %>
<% end %>
